package com.jtx.miaoah2.Controller;

import com.jtx.miaoah2.Common.BaseResponse;
import com.jtx.miaoah2.Model.goods.DO.SkGoodsSeckill;
import com.jtx.miaoah2.Service.SkGoodsSeckillService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 季台星
 * @Date 2023 07 23 16 49
 */
@RestController
@RequestMapping("/api/v1/Snapped")
public class SkSnappedController {
    @Autowired
    private SkGoodsSeckillService skGoodsSeckillService;
    /**
     * 创建商品秒杀任务
     * @param skGoodsSeckill
     * @return
     */
    @PostMapping("create")
    public BaseResponse createSnapped(@RequestBody SkGoodsSeckill skGoodsSeckill){
        return BaseResponse.success(skGoodsSeckillService.createSnapped(skGoodsSeckill));
    }

    @GetMapping("list/{pageNo}/{pageSize}")
    public BaseResponse getSnappedList(@PathVariable("pageNo") Integer pageNo,
                                       @PathVariable("pageSize") Integer pageSize){
        return skGoodsSeckillService.getSnappedList(pageNo,pageSize);
    }

    @GetMapping("{id}")
    public BaseResponse getSnappedById(@PathVariable("id") Long id){
        return skGoodsSeckillService.getSnappedById(id);
    }
}
